#include<bits/stdc++.h>
using namespace std;
int n,m,a[1001];
int cnt[1001];
int ans=0;
int n1;
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        ans=0;
        cin>>n1;
        for(int j=1;j<=n1;j++)
        {
            cin>>a[j];
            cnt[a[j]]++;
        }
        for(int j=1;j<=40;j++)
        {
            if(cnt[a[j]]>1)
            {
                cnt[a[j]]--;
                ans+=a[j];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
